package com.yh.autobio.common;

import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.utils.ViewPortHandler;

import java.text.DecimalFormat;

/**
 * Created by Administrator on 2016/3/31 0031.
 */
public class MyValueFormatter implements ValueFormatter {

    private DecimalFormat mFormat;

    public MyValueFormatter() {
        mFormat = new DecimalFormat("###,###,##0.0"); // use one decimal
    }

    @Override
    public String getFormattedValue(float value, Entry entry, int dataSetIndex, ViewPortHandler viewPortHandler) {
        // write your logic here
        return mFormat.format((float) (value / 1000)) + " 千"; // e.g. append a dollar-sign
    }

    public String getFormattedValueQain(float value) {
        // write your logic here
        return mFormat.format((float) (value / 1000)) + " 千"; // e.g. append a dollar-sign
    }

    public String getFormattedValueWan(float value) {
        // write your logic here
        return mFormat.format((float) (value / 10000)) + " 万"; // e.g. append a dollar-sign
    }

    public String getFormattedValueBai(float value) {
        // write your logic here
        return mFormat.format((float) (value / 100)) + " 百"; // e.g. append a dollar-sign
    }

    public String getFormattedValue2(float value) {
        // write your logic here
        return mFormat.format((float) (value)); // e.g. append a dollar-sign
    }

    public String formatFloat(float value) {
        if (value >= 10000) {
            return getFormattedValueWan(value);
        } else {
            return getFormattedValue2(value);
        }
    }
}
